﻿<%@ Page Language="C#" MasterPageFile="../../MasterPage.Master" AutoEventWireup="true" CodeBehind="ICM_Master_Resource.aspx.cs" Inherits="KPIS.GERP.GIMS.APP.APP_UI.Form.ICM_Master_Resource" %>
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
<%@ Register Src="~/APP_UI/UserControl/ICM_Master_Resource_Type.ascx" TagName="ResourceTypeControl" TagPrefix="GIMSControl" %>
<%@ Register Src="~/APP_UI/UserControl/ICM_Master_Resource_Group.ascx" TagName="ResourceGroupControl" TagPrefix="GIMSControl" %>
<%@ Register Src="~/APP_UI/UserControl/ICM_Master_Resource_Sub_Group.ascx" TagName="ResourceSubGroupControl" TagPrefix="GIMSControl" %>
<%@ Register Src="~/APP_UI/UserControl/ICM_Master_Resource_Item.ascx" TagName="ResourceItemControl" TagPrefix="GIMSControl" %>
<%@ Register Src="~/APP_UI/UserControl/Blank_Tree.ascx" TagName="BlankTreeControl" TagPrefix="GIMSControl" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="server">
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
            function CollapseSelectTree() {
                var treeview = $find('<%= RadTreeView1.ClientID %>');
                var selectedNode = treeview.get_selectedNode();
                if (selectedNode != null) {
                    selectedNode.collapse();
                }
                else {
                    var firstNode = treeview.findNodeByValue("0");
                    firstNode.collapse();
                }
            }
            function ExpandSelectTree() {
                var treeview = $find('<%= RadTreeView1.ClientID %>');
                var selectedNode = treeview.get_selectedNode();
                if (selectedNode != null) {
                    selectedNode.expand();
                }
                else {
                    var firstNode = treeview.findNodeByValue("0");
                    firstNode.expand();
                }
            }
            
            function RowDbClick(sender, eventArgs) {
                var hiddenElement = document.getElementById("<%= hdSeq.ClientID %>");
                hiddenElement.value = eventArgs.getDataKeyValue("Seq");
                $find("<%= RadManager1.ClientID %>").ajaxRequest(hiddenElement.value);
            }

            function SeqClick(seq) {
                var hiddenElement = document.getElementById("<%= hdSeq.ClientID %>");
                hiddenElement.value = seq;
                $find("<%= RadManager1.ClientID %>").ajaxRequest(seq);
            }

            function showImage() 
            {
                extArray = new Array(".gif", ".jpg", ".png", ".bmp");
                allowSubmit = false;
                var photo = document.getElementById('<%= ((Image)ResourceItemControl1.FindControl("imgPhoto")).ClientID %>');
                var file = document.getElementById('<%= ((System.Web.UI.HtmlControls.HtmlInputFile)ResourceItemControl1.FindControl("attachment")).ClientID %>');
                var div_part = document.getElementById('<%= ((System.Web.UI.HtmlControls.HtmlGenericControl)ResourceItemControl1.FindControl("uploadFile_div")).ClientID %>');
                var source_file = document.getElementById("<%= hdSourceFile.ClientID %>");
                var change_file = document.getElementById("<%= hdChangeFile.ClientID %>");
                value = file.value;
                if (value.length == 0) {
                    return;
                }
                while (value.indexOf("\\") != -1) {
                    value = value.slice(value.indexOf("\\") + 1);
                }
                ext = value.slice(value.indexOf(".")).toLowerCase();
                for (var i = 0; i < extArray.length; i++) {
                    if (ext.indexOf(extArray[i]) >= 0) {
                        allowSubmit = true; break; 
                    }
                }
                if (allowSubmit) {
                    source_file.value = file.value;
                    change_file.value = "1";
                    photo.src = file.value;
                }
                else {
                    alert("ไฟล์รูปภาพใช้ได้เฉพาะนามสกุล .gif, .jpg, .png, .bmp เท่านั้น");
                    div_part.innerHTML = div_part.innerHTML;
                }
            }

            function clearImage() 
            {
                var photo = document.getElementById('<%= ((Image)ResourceItemControl1.FindControl("imgPhoto")).ClientID %>');
                var source_file = document.getElementById("<%= hdSourceFile.ClientID %>");
                photo.src = "../Image/ItemPicture/Nopic.jpg";
                source_file.value = "";
            }

            function closeRadWindow(sender, args) {
                $find("<%= RadManager1.ClientID %>").ajaxRequest('CloseWindow');
            }

            function onTextChange(sender) {
                if (sender.get_value() == "") 
                {
                    sender.set_text("");
                }
            }
            
            function ExpandPersonal(sender, Args) {
                if (!sender._loaded) {
                    $find("<%=RadAjaxPanel1.ClientID %>").ajaxRequest();
                    sender._loaded = true;
                }
            }
            
            function cancelUndock(sender, Args) {
                Args.set_cancel(true);
            }
        </script>
    </telerik:RadCodeBlock>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" BackgroundPosition="None" Skin="Outlook">
    </telerik:RadAjaxLoadingPanel>
    <telerik:RadAjaxManager runat="server" ID="RadManager1" OnAjaxRequest="RadManager1_AjaxRequest">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="btnCollapse">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="PanelLeft" LoadingPanelID="RadAjaxLoadingPanel1"/>
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="btnSearch">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="PanelLeft" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="btnCancel">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="PanelLeft" LoadingPanelID="RadAjaxLoadingPanel1"/>
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="btnUser">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="btnUser"/>
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="RadTreeView1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadTreeView1" />
                    <telerik:AjaxUpdatedControl ControlID="PanelData" LoadingPanelID="RadAjaxLoadingPanel1"/>
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="PanelData">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadTreeView1" />
                    <telerik:AjaxUpdatedControl ControlID="PanelData" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="RadManager1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadTreeView1" />
                    <telerik:AjaxUpdatedControl ControlID="PanelData" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="ResourceTypeControl1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadTreeView1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="ResourceGroupControl1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadTreeView1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="ResourceSubGroupControl1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadTreeView1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="ResourceItemControl1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadTreeView1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    
    <asp:Panel ID="panelHidden" runat="server">
        <asp:HiddenField ID="hdSeq" runat="server" Value="" />
        <asp:HiddenField ID="hdSourceFile" runat="server" Value="" />
        <asp:HiddenField ID="hdChangeFile" runat="server" Value="" />
    </asp:Panel>
    
    <telerik:RadSplitter id="RadSplitter1" runat="server" height="460" width="1000" Skin="Office2007">
        <telerik:RadPane id="LeftPane" runat="server" width="22" Scrolling="None" Locked="true">
            <telerik:RadSlidingZone id="SlidingZone1" runat="server" width="22" ClickToOpen="true" DockedPaneId="PaneSearch">
                <telerik:RadSlidingPane id="PanePersonal" title="ข้อมูลส่วนตัว" runat="server" width="265" IconUrl="../Image/General/user.gif" EnableDock="false" OnClientBeforeExpand="ExpandPersonal">
                    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" OnAjaxRequest="OnAjaxRequest">
                    </telerik:RadAjaxPanel>
                </telerik:RadSlidingPane>
                <telerik:RadSlidingPane id="PaneSearch" title="โครงสร้าง" runat="server" width="345" IconUrl="../Image/Tree/treeview.gif" OnClientBeforeUndock="cancelUndock" Scrolling="None">
                    <table width="100%" cellpadding="0" cellspacing="0">
                        <tr>
                            <td></td>
                        </tr>
                        <tr>
                            <td>
                                <asp:Panel ID="PanelLeft" runat="server">
                                    <asp:Panel ID="PanelCommandTree" runat="server">
                                        <div class="bigModuleLeftTreeTab">
                                            <div class="bigModuleBottomLeftTreeTab">
                                                <table cellpadding="0" cellspacing="0">
                                                    <tr class="command-list">
                                                        <td class="command-item" style="border: none">
                                                            <asp:LinkButton ID="btnCollapse" runat="server" CssClass="LinkButton" OnClick="btnCollapse_Click" CausesValidation="false">
                                                            <img style="border:0px;vertical-align:middle;" alt="" src="../Image/Tree/collapse2.gif" />&nbsp;&nbsp;ซ่อนทั้งหมด
                                                            </asp:LinkButton> 
                                                        </td>
                                                        <td class="command-item">
                                                            <telerik:RadTextBox ID="txtSearch" runat="server" Skin="Outlook" Width="70" ToolTip="กรุณาใส่ข้อความที่ต้องการค้นหา"></telerik:RadTextBox>
                                                            <asp:LinkButton ID="btnSearch" runat="server" CssClass="LinkButton" OnClick="btnSearch_Click" CausesValidation="false">
                                                                <img style="border:0px;vertical-align:middle;" alt="" src="../Image/Tree/search.gif" />&nbsp;&nbsp;ค้นหา
                                                            </asp:LinkButton>
                                                        </td>
                                                        <td class="command-item">
                                                            <asp:LinkButton ID="btnHelp" runat="server" CssClass="LinkButton">
                                                                <img style="border:0px;vertical-align:middle;" alt="" src="../Image/Tree/help3.gif" />&nbsp;&nbsp;ช่วยเหลือ
                                                            </asp:LinkButton>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td colspan="3">
                                                            <asp:Panel ID="PanelSearch" runat="server" Visible="false">
                                                                <table width="100%"  cellpadding="0" cellspacing="0">
                                                                    <tr>
                                                                        <td>
                                                                            <asp:Label ID="lblSearch" runat="server" Text="ผลการค้นหา : "  Font-Size="Small" ForeColor="Blue"></asp:Label>
                                                                            <asp:Label ID="lblSearch1" runat="server" Text="พบรายการเป็นจำนวน "  Font-Size="Small"></asp:Label>
                                                                            <asp:Label ID="lblResult" runat="server"  Font-Size="Small" ForeColor="#006600"></asp:Label>
                                                                            <asp:Label ID="lblSearch2" runat="server" Text=" รายการ" Font-Size="Small"></asp:Label>
                                                                        </td>
                                                                        <td align="right">
                                                                            <asp:LinkButton ID="btnCancel" runat="server" CssClass="LinkButton" OnClick="btnCancel_Click">
                                                                                <img style="border:0px;vertical-align:middle;" alt="" src="../Image/Grid/Cancel.gif" />&nbsp;ยกเลิก
                                                                            </asp:LinkButton>
                                                                        </td>
                                                                    </tr>
                                                                </table>
                                                            </asp:Panel>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </div>
                                        </div>
                                        <telerik:RadToolTip runat="server" ID="RadToolTip1" Width="300px" Height="70px" 
                                        TargetControlID="btnHelp" ShowEvent="OnClick" IsClientID="false" Animation="Fade" HideEvent="LeaveToolTip" 
                                        Position="BottomCenter" Skin="Web20">
                                            <table width="100%">
                                                <tr class="table-outlook-header">
                                                    <td>
                                                        <asp:Label ID="lblHeader1" runat="server" Text="คำอธิบายรูปภาพ" Font-Size="Small" ForeColor="White" Font-Bold="true"></asp:Label>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <asp:Image ID="imgFolder1" runat="server" ImageUrl="~/APP_UI/Image/Tree/folder-1.gif"></asp:Image><asp:Label ID="lblFolder1" runat="server" Text=" = ประเภทพัสดุ" Font-Size="Small"></asp:Label><br />
                                                        <asp:Image ID="imgFolder2" runat="server" ImageUrl="~/APP_UI/Image/Tree/folder-2.gif"></asp:Image><asp:Label ID="lblFolder2" runat="server" Text=" = หมวดพัสดุ" Font-Size="Small" ></asp:Label><br />
                                                        <asp:Image ID="imgFolder3" runat="server" ImageUrl="~/APP_UI/Image/Tree/folder-3.gif"></asp:Image><asp:Label ID="lblFolder3" runat="server" Text=" = กลุ่มพัสดุ" Font-Size="Small" ></asp:Label><br />
                                                        <asp:Image ID="imgFolder4" runat="server" ImageUrl="~/APP_UI/Image/Tree/folder-4.gif"></asp:Image><asp:Label ID="lblFolder4" runat="server" Text=" = รายการพัสดุ" Font-Size="Small" ></asp:Label> 
                                                    </td>
                                                </tr>
                                                <tr class="table-outlook-header">
                                                    <td>
                                                        <asp:Label ID="lblHeader2" runat="server" Text="แหล่งอ้างอิง" Font-Size="Small" ForeColor="White" Font-Bold="true"></asp:Label>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <asp:Label ID="Detail2" runat="server" Text="จำแนกประเภทพัสดุตามบัญชีมาตรฐานครุภัณฑ์ของสำนักงบประมาณ" Font-Size="Small"></asp:Label>
                                                    </td>
                                                </tr>
                                            </table>
                                        </telerik:RadToolTip>
                                    </asp:Panel>
                                    <div class="bigModuleLeftTreeTab">
                                        <div class="bigModuleBottomLeftTreeTab">
                                            <asp:Panel ID="panelHeaderList" runat="server">
                                                <div class="header-grid">
                                                    <asp:Label ID="lblHeaderList" runat="server" Text="โครงสร้างการจำแนกพัสดุ"></asp:Label>
                                                </div>
                                            </asp:Panel>
                                            <asp:Panel CssClass="panelWideTree" ID="PanelTree" runat="server" ScrollBars="Auto">
                                                <telerik:RadTreeView CssClass="TreeView" ID="RadTreeView1" runat="server" Skin="Outlook" DataTextField="Name" DataFieldID="Id" CausesValidation="false"
                                                DataFieldParentID="Parent_id" DataValueField="Id" OnNodeExpand="RadTreeView1_NodeExpand" OnNodeClick="RadTreeView1_NodeClick">
                                                    <CollapseAnimation Duration="0" Type="None" />
                                                    <ExpandAnimation Duration="0" Type="None" />
                                                    <DataBindings>
                                                        <telerik:RadTreeNodeBinding ImageUrlField="Image_url" />
                                                    </DataBindings>
                                                </telerik:RadTreeView>
                                            </asp:Panel>
                                        </div>
                                    </div>
                                </asp:Panel>
                            </td>
                        </tr>
                    </table>
                </telerik:RadSlidingPane>
            </telerik:RadSlidingZone>
        </telerik:RadPane>
        <telerik:RadSplitBar id="RadSplitBar1" runat="server"></telerik:RadSplitBar>
        <telerik:RadPane id="PaneData" runat="server" Scrolling="None">
            <asp:Panel ID="PanelData" runat="server">
                <GIMSControl:ResourceTypeControl id="ResourceTypeControl1" runat="server"></GIMSControl:ResourceTypeControl>
                <GIMSControl:ResourceGroupControl id="ResourceGroupControl1" runat="server" Visible="false"></GIMSControl:ResourceGroupControl>
                <GIMSControl:ResourceSubGroupControl id="ResourceSubGroupControl1" runat="server" Visible="false"></GIMSControl:ResourceSubGroupControl>
                <GIMSControl:ResourceItemControl id="ResourceItemControl1" runat="server" Visible="false"></GIMSControl:ResourceItemControl>
                <GIMSControl:BlankTreeControl id="BlankTreeControl1" runat="server" Visible="false"></GIMSControl:BlankTreeControl>
            </asp:Panel>
        </telerik:RadPane>
    </telerik:RadSplitter>
    <telerik:RadWindowManager ID="RadWindowManager1" ShowContentDuringLoad="false" VisibleStatusbar="false" ReloadOnShow="true" 
    runat="server" Skin="Vista" Modal="true" KeepInScreenBounds="true" Style="z-index: 7001">
        <Windows>
            <telerik:RadWindow ID="WindowDelete" runat="server" Width="660px" Height="600px" Behaviors="Default" OnClientClose="closeRadWindow">
            </telerik:RadWindow>
        </Windows>
    </telerik:RadWindowManager>
</asp:Content>
